﻿var RootPath = GetRootPath();
function GetRootPath() {
    var loc = window.location,
        host = loc.hostname,
        protocol = loc.protocol,
        port = loc.port ? (':' + loc.port) : '';
    var path = location.pathname;

    if (path.indexOf('/') === 0) {
        path = path.substring(1);
    }

    var mypath = '/' + path.split('/')[0];
    path = (mypath != undefined ? mypath : ('/' + loc.pathname.split('/')[1])) + '/';

    var rootPath = protocol + '//' + host + port + path;
    return rootPath;
}

var LocalDataPrefix = "knife_";

function SetLocalData(key, data) {
    localStorage.setItem(LocalDataPrefix + key, data);
}

function GetLocalData(key) {
    return localStorage.getItem(LocalDataPrefix + key);
}

function GetSystemTheme() {
    var Theme = GetLocalData("Theme");
    if (Theme == null) {
        Theme = 'base';
    }
    return Theme;
}

function GetVersion() {
    return "2022.04.06.001"
}
function LoadCSS(url, islocal) {
    var version = GetVersion();
    if (islocal) {
        url += "?version=" + version;
    }
    document.write('<link rel="stylesheet" href= ' + url + '></link>');
}
function LoadJS(url, islocal) {
    var version = GetVersion();
    if (islocal) {
        url += "?version=" + version;
    }
    document.write('<script src= ' + url + '></script>');
}

LoadCSS(RootPath + "Resources/lib/zui/css/zui.min.css", false);
LoadCSS(RootPath + "Resources/css/knife.common.css", false);
LoadCSS(RootPath + "Resources/lib/dialog/dialog.css", false);
LoadCSS(RootPath + "Resources/lib/table/table.css", false);

LoadJS(RootPath + "Resources/lib/jquery/jquery.js", false)
LoadJS(RootPath + "Resources/js/knife.commom.js", false)
LoadJS(RootPath + "Resources/lib/dialog/dialog.js", false)
LoadJS(RootPath + "Resources/lib/table/table.js", false)
LoadJS(RootPath + "Resources/lib/zui/js/zui.min.js", false)